1
|
|
|
2
|
|
|
3
|
|
|
4
|
|
|
5
|
|
|
6
|
|
|
7
|
|
|
8
|
|
|
9
|
|
|
10
|
|
|
11
|
|
|
12
|
|
|
13
|
|
|
14
|
|
|
15
|
|
|
16
|
|
|
17
|
|
package org.apache.geronimo.ews.ws4j2ee.context;
|
18
|
|
|
19
|
|
import org.apache.axis.wsdl.fromJava.Emitter;
|
20
|
|
import org.apache.axis.wsdl.symbolTable.BindingEntry;
|
21
|
|
import org.apache.axis.wsdl.symbolTable.Parameter;
|
22
|
|
import org.apache.axis.wsdl.symbolTable.Parameters;
|
23
|
|
import org.apache.axis.wsdl.symbolTable.PortEntry;
|
24
|
|
import org.apache.axis.wsdl.symbolTable.PortTypeEntry;
|
25
|
|
import org.apache.axis.wsdl.symbolTable.ServiceEntry;
|
26
|
|
import org.apache.geronimo.ews.ws4j2ee.context.impl.EJBDDContextImpl;
|
27
|
|
import org.apache.geronimo.ews.ws4j2ee.context.impl.SEIOperationImpl;
|
28
|
|
import org.apache.geronimo.ews.ws4j2ee.context.j2eeDD.EJBContext;
|
29
|
|
import org.apache.geronimo.ews.ws4j2ee.context.webservices.server.interfaces.WSCFPortComponent;
|
30
|
|
import org.apache.geronimo.ews.ws4j2ee.context.webservices.server.interfaces.WSCFWebserviceDescription;
|
31
|
|
import org.apache.geronimo.ews.ws4j2ee.toWs.GenerationFault;
|
32
|
|
import org.apache.geronimo.ews.ws4j2ee.toWs.UnrecoverableGenerationFault;
|
33
|
|
|
34
|
|
import javax.wsdl.Fault;
|
35
|
|
import javax.wsdl.Operation;
|
36
|
|
import javax.wsdl.Port;
|
37
|
|
import javax.wsdl.Service;
|
38
|
|
import javax.xml.namespace.QName;
|
39
|
|
import java.util.Collection;
|
40
|
|
import java.util.Iterator;
|
41
|
|
import java.util.List;
|
42
|
|
import java.util.Map;
|
43
|
|
|
44
|
|
|
45
|
|
|
46
|
|
|
47
|
|
|
48
|
|
|
49
|
|
|
50
|
|
|
51
|
|
|
52
|
|
public class ContextValidator {
|
53
|
|
private J2EEWebServiceContext context;
|
54
|
|
|
55
|
26
|
public ContextValidator(J2EEWebServiceContext context) throws GenerationFault {
|
56
|
26
|
try {
|
57
|
26
|
this.context = context;
|
58
|
|
} catch (Exception e) {
|
59
|
0
|
e.printStackTrace();
|
60
|
0
|
throw GenerationFault.createGenerationFault(e);
|
61
|
|
}
|
62
|
|
}
|
63
|
|
|
64
|
|
|
65
|
|
|
66
|
|
|
67
|
|
|
68
|
|
|
69
|
|
|
70
|
|
|
71
|
11
|
public void validateWithOutWSDL(Emitter emitter) throws GenerationFault {
|
72
|
11
|
try {
|
73
|
11
|
Collection servicesCollection = context.getWSDLContext().getServices();
|
74
|
11
|
if (servicesCollection.size() > 1)
|
75
|
0
|
throw new UnrecoverableGenerationFault("we are supporting one service yet");
|
76
|
11
|
Iterator services = servicesCollection.iterator();
|
77
|
11
|
Service service = null;
|
78
|
11
|
if (services.hasNext()) {
|
79
|
11
|
service = ((Service) services.next());
|
80
|
11
|
context.getWSDLContext().settargetService(new ServiceEntry(service));
|
81
|
|
}
|
82
|
|
|
83
|
|
|
84
|
11
|
Collection portCollecton = service.getPorts().values();
|
85
|
|
|
86
|
|
|
87
|
11
|
if (servicesCollection.size() > 1)
|
88
|
0
|
throw new UnrecoverableGenerationFault("we are supporting one port yet");
|
89
|
11
|
Iterator portList = portCollecton.iterator();
|
90
|
11
|
Port wsdlport = null;
|
91
|
11
|
while (portList.hasNext()) {
|
92
|
11
|
wsdlport = (Port) portList.next();
|
93
|
11
|
context.getWSDLContext().setTargetPort(wsdlport);
|
94
|
|
}
|
95
|
11
|
if (wsdlport == null)
|
96
|
0
|
throw new UnrecoverableGenerationFault("no port discription not match with the wsdl file");
|
97
|
11
|
QName bindingName = wsdlport.getBinding().getQName();
|
98
|
11
|
BindingEntry wsdlbinding = context.getWSDLContext().getBinding(bindingName);
|
99
|
11
|
context.getWSDLContext().settargetBinding(wsdlbinding);
|
100
|
11
|
QName portTypename = wsdlbinding.getBinding().getPortType().getQName();
|
101
|
11
|
PortTypeEntry port = context.getWSDLContext().getPortType(portTypename);
|
102
|
11
|
if (port == null)
|
103
|
0
|
throw new UnrecoverableGenerationFault("port type must exits");
|
104
|
11
|
context.getWSDLContext().setTargetPortType(port);
|
105
|
|
} catch (Exception e) {
|
106
|
0
|
e.printStackTrace();
|
107
|
0
|
throw GenerationFault.createGenerationFault(e);
|
108
|
|
}
|
109
|
|
}
|
110
|
|
|
111
|
11
|
public void validateWithWSDL() {
|
112
|
11
|
WSCFWebserviceDescription wscfwsdis = context.getWSCFContext().getWscfdWsDesxription();
|
113
|
11
|
WSCFPortComponent[] ports = wscfwsdis.getPortComponent();
|
114
|
11
|
if (ports == null || ports.length == 0)
|
115
|
0
|
throw new UnrecoverableGenerationFault("no port discription found in the" +
|
116
|
|
"webservices.xml file");
|
117
|
11
|
WSCFPortComponent port = ports[0];
|
118
|
11
|
context.getWSCFContext().setWscfport(port);
|
119
|
11
|
String ejbLink = port.getServiceImplBean().getEjblink();
|
120
|
|
|
121
|
11
|
if (ejbLink != null) {
|
122
|
8
|
String bean = port.getServiceEndpointInterface() + "Bean";
|
123
|
8
|
String home = port.getServiceEndpointInterface() + "Home";
|
124
|
8
|
String remote = port.getServiceEndpointInterface() + "EJB";
|
125
|
8
|
String local = port.getServiceEndpointInterface() + "LocalEJB";
|
126
|
8
|
String localHome = port.getServiceEndpointInterface() + "LocalHome";
|
127
|
8
|
EJBContext ejbcontext = context.getEJBDDContext();
|
128
|
8
|
if (ejbcontext == null) {
|
129
|
0
|
ejbcontext = new EJBDDContextImpl(ejbLink, bean, home, remote, localHome, local);
|
130
|
|
}
|
131
|
|
|
132
|
8
|
if (ejbcontext.getImplBean() == null)
|
133
|
0
|
ejbcontext.setImplBean(bean);
|
134
|
8
|
if (ejbcontext.getEjbhomeInterface() == null)
|
135
|
0
|
ejbcontext.setEjbhomeInterface(home);
|
136
|
8
|
if (ejbcontext.getEjbRemoteInterface() == null)
|
137
|
0
|
ejbcontext.setEjbRemoteInterface(remote);
|
138
|
8
|
if (ejbcontext.getEjbLocalHomeInterfce() == null)
|
139
|
8
|
ejbcontext.setEjbLocalHomeInterfce(localHome);
|
140
|
8
|
if (ejbcontext.getEjbLocalInterface() == null)
|
141
|
8
|
ejbcontext.setEjbLocalHomeInterfce(local);
|
142
|
8
|
context.getMiscInfo().setJ2eeComponetLink(port.getServiceImplBean().getEjblink());
|
143
|
|
} else {
|
144
|
3
|
context.getMiscInfo().setImplwithEJB(false);
|
145
|
|
}
|
146
|
11
|
QName portName = new QName(port.getWsdlPort().getNamespaceURI(), port.getWsdlPort().getLocalpart());
|
147
|
11
|
PortEntry wsdlport = context.getWSDLContext().getPort(portName);
|
148
|
11
|
if (wsdlport == null)
|
149
|
0
|
throw new UnrecoverableGenerationFault("wsdl port can not be null, you may have the " +
|
150
|
|
"wsdlport define wrongly on the webservices.xml");
|
151
|
11
|
Iterator services = context.getWSDLContext().getServices().iterator();
|
152
|
11
|
while (services.hasNext()) {
|
153
|
11
|
ServiceEntry service = (ServiceEntry) services.next();
|
154
|
11
|
Iterator portList = service.getService().getPorts().values().iterator();
|
155
|
11
|
while (portList.hasNext()) {
|
156
|
11
|
if (((Port) portList.next()) == wsdlport.getPort()) {
|
157
|
11
|
context.getWSDLContext().settargetService(service);
|
158
|
11
|
break;
|
159
|
|
}
|
160
|
|
}
|
161
|
|
}
|
162
|
11
|
if (wsdlport == null)
|
163
|
0
|
throw new UnrecoverableGenerationFault("no port discription not match with the wsdl file");
|
164
|
11
|
QName bindingName = wsdlport.getPort().getBinding().getQName();
|
165
|
11
|
BindingEntry wsdlbinding = context.getWSDLContext().getBinding(bindingName);
|
166
|
11
|
context.getWSDLContext().settargetBinding(wsdlbinding);
|
167
|
11
|
QName portTypename = wsdlbinding.getBinding().getPortType().getQName();
|
168
|
11
|
context.getWSDLContext().setTargetPortType(context.getWSDLContext().getPortType(portTypename));
|
169
|
11
|
context.validate();
|
170
|
|
|
171
|
|
|
172
|
|
|
173
|
11
|
String seiName = context.getJAXRPCMappingContext()
|
174
|
|
.getServiceEndpointInterfaceName(context.getWSDLContext().getTargetPortType(), context.getWSDLContext().gettargetBinding());
|
175
|
11
|
context.getMiscInfo().setJaxrpcSEI(seiName);
|
176
|
11
|
List operations = context.getWSDLContext().getTargetPortType().getPortType().getOperations();
|
177
|
11
|
for (int i = 0; i < operations.size(); i++) {
|
178
|
40
|
SEIOperation seiOp = new SEIOperationImpl();
|
179
|
40
|
Operation op = (Operation) operations.get(i);
|
180
|
40
|
BindingEntry binding = context.getWSDLContext().gettargetBinding();
|
181
|
|
|
182
|
|
|
183
|
|
|
184
|
40
|
Parameters parms = binding.getParameters(op);
|
185
|
|
|
186
|
40
|
String returnType = context.getJAXRPCMappingContext().getJavaMethodReturnType(binding, op);
|
187
|
40
|
seiOp.setReturnType(returnType);
|
188
|
|
|
189
|
|
|
190
|
|
|
191
|
40
|
String methodName = context.getJAXRPCMappingContext().getJavaMethodName(binding, op);
|
192
|
40
|
seiOp.setMethodName(methodName);
|
193
|
|
|
194
|
|
|
195
|
40
|
String parameterName = null;
|
196
|
40
|
String parameterType = null;
|
197
|
|
|
198
|
|
|
199
|
40
|
for (int paramCount = 0; paramCount < parms.list.size(); paramCount++) {
|
200
|
54
|
Parameter p = (Parameter) parms.list.get(paramCount);
|
201
|
54
|
parameterName = p.getName();
|
202
|
54
|
parameterType = context.getJAXRPCMappingContext().getJavaMethodParamType(binding, op, paramCount, p.getType().getQName());
|
203
|
54
|
seiOp.addParameter(parameterType, parameterName);
|
204
|
|
}
|
205
|
|
|
206
|
40
|
Map faults = parms.faults;
|
207
|
40
|
if (faults != null) {
|
208
|
40
|
Iterator it = faults.values().iterator();
|
209
|
40
|
while (it.hasNext()) {
|
210
|
0
|
Fault fault = (Fault) it.next();
|
211
|
0
|
String faulltName = context.getJAXRPCMappingContext()
|
212
|
|
.getExceptionType(fault.getMessage().getQName());
|
213
|
0
|
seiOp.addFault(faulltName);
|
214
|
|
}
|
215
|
|
}
|
216
|
40
|
context.getMiscInfo().setSEIOperations(seiOp);
|
217
|
|
}
|
218
|
|
|
219
|
|
|
220
|
|
|
221
|
|
}
|
222
|
|
}
|
223
|
|
|